﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Forum.Master" AutoEventWireup="true" CodeBehind="DangBai.aspx.cs" Inherits="Client.WebForm10" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<script type="text/javascript" src="Scripts/json2.js"></script>
<script type="text/javascript" src="Scripts/json_parse.js"></script>
<script type="text/javascript" src="Scripts/json_parse_state.js"></script>
<script type="text/javascript" src="Scripts/cycle.js"></script>
<script type="text/javascript" src="Scripts/1.js"></script> 
<script src="http://code.jquery.com/jquery-latest.js"></script>
 <script src="Scripts/jquery-1.8.2.js"></script>
    <script src="Scripts/jquery-ui-1.9.1.custom.js"></script>
    <link rel="stylesheet" href="Styles/jquery-ui-1.9.2.custom.css" />
    <link rel="stylesheet" href="Styles/ThuNhoAnh.css"/>
    <link rel="stylesheet" href="Styles/jquery-ui.css" />
    <style type="text/css">
       
}
        .style7
        {
            height: 22px;
            width:70px;
        }
        #TextArea1
        {
            width: 532px;
            height: 315px;
        }
        #Text1
        {
            width: 274px;
        }
        #Tittle
        {
            width: 271px;
        }
        #Place
        {
            width: 272px;
        }
    </style>
    <script>
        $(function () {
            var URL = 'http://localhost:18796/api/values/';
            $("#XemThuNoiDung").hide();
            $("#HuyXemThu").hide();
            $.fx.speeds._default = 1000;
            $("#linkurl").dialog({
                autoOpen: false,
                show: "blind",
                hide: "explode",
                buttons: {
                    Add: function () {
                        var url = $("#textlinkurl").val();
                        var mota = $("#text1linkurl").val();
                        document.getElementById("TextArea1").value = document.getElementById("TextArea1").value +
                        "<a href='" + url + "'>" + mota + "</a>";
                        $(this).dialog("close");
                    },
                    Cancel: function () {
                        $(this).dialog("close");
                    }
                }
            });
            $("#imgurl").dialog({
                autoOpen: false,
                show: "blind",
                hide: "explode",
                buttons: {
                    Add: function () {
                        var url = $("#textimgurl").val();
                        document.getElementById("TextArea1").value = document.getElementById("TextArea1").value +
                        "<img src='" + url + "'></img>";
                        $(this).dialog("close");
                    },
                    Cancel: function () {
                        $(this).dialog("close");
                    }
                }
            });
            $("#TextQuote").dialog({
                autoOpen: false,
                show: "blind",
                hide: "explode",
                buttons: {
                    Add: function () {
                        var url = $("#ContentQuote").val();
                        document.getElementById("TextArea1").value = document.getElementById("TextArea1").value +
                        '<blockquote>" ' + url + ' "</blockquote>';
                        $(this).dialog("close");
                    },
                    Cancel: function () {
                        $(this).dialog("close");
                    }
                }
            });
            $("#bold")
            .button()
            .click(function () {
                document.getElementById("TextArea1").value = document.getElementById("TextArea1").value + "<b></b>";
            });
            $("#italic")
            .button()
            .click(function () {
                document.getElementById("TextArea1").value = document.getElementById("TextArea1").value + "<i></i>";
            });
            $("#underline")
            .button()
            .click(function () {
                document.getElementById("TextArea1").value = document.getElementById("TextArea1").value + "<u></u>";
            });
            $("#removeformat")
            .button()
            .click(function () {
                var a = document.getElementById("TextArea1").value;
                a = a.replace('<b>', '');
                a = a.replace('</b>', '');
                a = a.replace('<u>', '');
                a = a.replace('</u>', '');
                a = a.replace('<i>', '');
                a = a.replace('</i>', '');
                document.getElementById("TextArea1").value = a;
            });
            $("#createlink")
            .button()
            .click(function () {
                $("#linkurl").dialog("open");
            });
            $("#insertimage")
            .button()
            .click(function () {
                $("#imgurl").dialog("open");
            });
            $("#quote")
            .button()
            .click(function () {
                $("#TextQuote").dialog("open");
            });
            $("#XemThu")
            .button()
            .click(function () {
                $("#NoiDung").hide();
                $("#HuyXemThu").show();
                var a = document.getElementById("TextArea1").value;
                $("#XemThuNoiDung").show();
                $("#XemThuNoiDung").append(a);
                $("#XemThu").hide();
            });
            $("#DangBai")
            .button()
            .click(function () {
                var tuade = $("#Tittle").val();
                var ngaydang = ""
               
                var nguoidang = <%=ReturnName() %>;
                var noidung=document.getElementById("TextArea1").value;
                alert(noidung);
                jQuery.support.cors = true;
                $.ajax({
                    url: URL + '?tuade=' +tuade+ '&ngaydang='+ngaydang + '&nguoidang='+nguoidang + '&noidung='+noidung,
                    type: 'GET',

                    datatype: 'json',

                    success: function (data) {
                        if (data == true)
                            {
                                alert("Đăng Thành Công");
                                document.getElementById("TextArea1").value="";
                                $("#Tittle").val()="";
                            }
                        else
                            alert("Đăng Thất Bại, Hãy Thử Lại ...");
                    },
                    error: function () {
                        alert("Hãy xóa bớt phần không cần thiết !");
                    }
                });
            });
            $("#HuyXemThu")
            .button()
            .click(function () {
                $("#XemThuNoiDung").empty();
                $("#XemThuNoiDung").hide();
                $("#NoiDung").show();
                $("#XemThu").show();
                $("#HuyXemThu").hide();
            });
            $("#HuyBo")
            .button()
            .click(function () {
                window.location = "MainBlog.aspx";
            });
             $("#Br")
            .button()
            .click(function () {
                document.getElementById("TextArea1").value = document.getElementById("TextArea1").value +"<Br>";
            });
        });
    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
        <div id="linkurl" title="Thêm Link">
     <fieldset class="ui-helper-reset">
            <label for="tab_title">URL Link</label>
            <input type="text" name="tab_title" id="textlinkurl" value="" class="ui-widget-content ui-corner-all" />   
            <br />
            <label for="tab_title">Mô Tả   </label>
            <input type="text" name="tab_title" id="text1linkurl" value="" class="ui-widget-content ui-corner-all" />          
        </fieldset>
    </div>
    <div id="imgurl" title="Thêm Hình">
     <fieldset class="ui-helper-reset">
            <label for="tab_title">URL Image</label>
            <input type="text" name="tab_title" id="textimgurl" value="" class="ui-widget-content ui-corner-all" />         
        </fieldset>
    </div>
    <div id="TextQuote" title="Thêm Hình">
     <fieldset class="ui-helper-reset">
            <label for="tab_title">Trích Dẫn</label>
            <input type="text" name="tab_title" id="ContentQuote" value="" class="ui-widget-content ui-corner-all" />         
        </fieldset>
    </div>
    <div style="height:auto;width:100%;padding-right:0px">
        

        <div style="width: 548px">
            <div style="float:inherit; height: auto; width: 100%; background-color: #FFFFFF;">
            <div align="center" 
                    style="float:inherit;height: 50px;width: 100%; background-color: #444444; ">
                
                <br />
                
                <asp:Label ID="Label16" runat="server" Font-Bold="True" Font-Size="XX-Large" 
                    ForeColor="White" Text="Đăng Bài Mới"></asp:Label>
            </div>
        </div>
    </div>
    <div>
    <div style="padding-top:10px">
    Tiêu đề :&nbsp;&nbsp;&nbsp;&nbsp;
        <input id="Tittle" type="text" /></div>
    
    </div>
    <div id="XemThuNoiDung" class="content_section">

    </div>
        <table style="width: 100%;" border="1" cellpadding="1" cellspacing="1">
            <tr>
                <td bgcolor="#CCCCCC" width="12%" align="center">
                     <button type="button" id="removeformat"> <img src="imgDangBai/removeformat.gif" /></button>
                </td>
                <td bgcolor="#CCCCCC" width="12%" align="center">
                    <button type="button" id="bold"> <img src="imgDangBai/bold.gif" /></button></td>
                <td bgcolor="#CCCCCC" width="12%" align="center">
                    <button type="button" id="italic"> <img src="imgDangBai/italic.gif" /></button></td>
                <td bgcolor="#CCCCCC" width="12%" align="center">
                    <button type="button" id="underline"> <img src="imgDangBai/underline.gif" /></button></td>
                <td bgcolor="#CCCCCC" width="13%" align="center">
                    <button type="button" id="createlink"> <img src="imgDangBai/createlink.gif" /></button></td>
                <td bgcolor="#CCCCCC" width="13%" align="center">
                    <button type="button" id="insertimage"> <img src="imgDangBai/insertimage.gif" /></button></td>
                <td bgcolor="#CCCCCC" width="13%" align="center">
                    <button type="button" id="quote"> <img src="imgDangBai/quote.gif" /></button></td>
                <td bgcolor="#CCCCCC" width="13%" align="center">
                    <input id="Br" type="button" value="<Br>" /></td>
            </tr>
            <tr>
                <td colspan="8">
                    <textarea id="TextArea1" name="S1"></textarea>
                </td>
            </tr>
            </table>

        <table border="1" cellpadding="1" cellspacing="1" style="width:98%;">
         <tr>
                <td colspan="3" align="center" width="33%">
                    <input id="XemThu" type="button" value="Xem Thử" />
                    <input id="HuyXemThu" type="button" value="Hủy Xem Thử" /></td>
                <td colspan="3" align="center" width="33%">
                    <input id="DangBai" type="button" value="Đăng Bài" /></td>
                <td colspan="3" align="center" width="33%">
                    <input id="HuyBo" type="button" value="Hủy Bỏ" /></td>
            </tr>
        </table>
    </div>
        
</asp:Content>